package tianrun.ziguan.api.calculate.config.service.asset.instance.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import tianrun.ziguan.api.calculate.config.dao.TAssetIndicatorsInstanceMapper;
import tianrun.ziguan.api.calculate.config.dto.request.AssetIndicatorsInstanceVO;
import tianrun.ziguan.api.calculate.config.entity.TAssetIndicatorsInstance;
import tianrun.ziguan.api.calculate.config.service.asset.instance.ITAssetIndicatorsInstanceService;
import tianrun.ziguan.api.calculate.config.utils.CollectionUtil;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
 * @author zhaoqi
 */
@Service
public class TAssetIndicatorsInstanceServiceImpl extends ServiceImpl<TAssetIndicatorsInstanceMapper, TAssetIndicatorsInstance> implements ITAssetIndicatorsInstanceService {

    @Override
    public List<AssetIndicatorsInstanceVO> queryInstanceList(List<Long> calAssetIds, String type) {
        return baseMapper.queryInstanceList(calAssetIds, type);
    }

    @Override
    public Collection<TAssetIndicatorsInstance> listByModuleIds(Set<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return list(Wrappers.<TAssetIndicatorsInstance>lambdaQuery().eq(TAssetIndicatorsInstance::getIsValid, true).in(TAssetIndicatorsInstance::getModuleId, ids));
    }

    @Override
    public Collection<AssetIndicatorsInstanceVO> listVOByCalAssetIds(Set<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return baseMapper.listVOByCalAssetId(ids);
    }
}
